﻿/*
This file is under Microsoft Public License (MS-PL)
Copyright Yohann MARTEL.  All rights reserved.
Codeplex: http://amf.codeplex.com
AMF Website: http://www.ymartel.com/aspnet-mobile-framework/
*/
using System;
using System.Web.UI;

namespace Mobile.WebControls
{
    public static class IconLinkHelper
    {
        #region Render Methods
        public static void RenderPosition(HtmlTextWriter writer, IconPosition iconPosition)
        {
            string position = String.Empty;
            switch (iconPosition)
            {
                case IconPosition.Left:
                case IconPosition.Bottom:
                case IconPosition.Right:
                case IconPosition.Top:
                case IconPosition.NoText:
                    position = Enum.GetName(typeof(IconPosition), iconPosition).ToLower();
                    break;
            }
            if (!String.IsNullOrEmpty(position))
            {
                writer.AddAttribute(MetadataAttribute.DataIconpos, position);
            }
        }

        public static void RenderDataIcon(HtmlTextWriter writer, DataIcon icon)
        {
            string dataIcon = String.Empty;
            switch (icon)
            {
                case DataIcon.LeftArrow:
                    dataIcon = "arrow-l";
                    break;
                case DataIcon.RightArrow:
                    dataIcon = "arrow-r";
                    break;
                case DataIcon.UpArrow:
                    dataIcon = "arrow-u";
                    break;
                case DataIcon.DownArrow:
                    dataIcon = "arrow-d";
                    break;
                case DataIcon.Delete:
                case DataIcon.Plus:
                case DataIcon.Minus:
                case DataIcon.Check:
                case DataIcon.Gear:
                case DataIcon.Refresh:
                case DataIcon.Forward:
                case DataIcon.Back:
                case DataIcon.Grid:
                case DataIcon.Star:
                case DataIcon.Alert:
                case DataIcon.Info:
                case DataIcon.Home:
                case DataIcon.Search:
                    dataIcon = Enum.GetName(typeof(DataIcon), icon).ToLower();
                    break;
            }
            if (!String.IsNullOrEmpty(dataIcon))
            {
                writer.AddAttribute(MetadataAttribute.DataIcon, dataIcon);
            }
        }
        #endregion
    }
}
